package com.shop.storage.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.shop.storage.vo.response.ForewarningResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shop.common.log.annotation.Log;
import com.shop.common.log.enums.BusinessType;
import com.shop.common.security.annotation.RequiresPermissions;
import com.shop.storage.domain.WmsForewarning;
import com.shop.storage.service.IWmsForewarningService;
import com.shop.common.core.web.controller.BaseController;
import com.shop.common.core.domain.Result;
import com.shop.common.core.utils.poi.ExcelUtil;


/**
 * 预警表Controller
 *
 * @author czb
 * @date 2024-06-26
 */
@RestController
@RequestMapping("/forewarning")
public class WmsForewarningController extends BaseController
{
    @Autowired
    private IWmsForewarningService wmsForewarningService;

/**
 * 查询预警表列表
 */
@RequiresPermissions("storage:forewarning:list")
@GetMapping("/list")
    public Result list(WmsForewarning wmsForewarning)
    {
        startPage();
        List<ForewarningResponse> list = wmsForewarningService.selectWmsForewarningList(wmsForewarning);
        return getDataTable(list);
    }

    /**
     * 导出预警表列表
     */
    @RequiresPermissions("storage:forewarning:export")
    @Log(title = "预警表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsForewarning wmsForewarning)
    {
        List<ForewarningResponse> list = wmsForewarningService.selectWmsForewarningList(wmsForewarning);
        ExcelUtil<ForewarningResponse> util = new ExcelUtil<ForewarningResponse>(ForewarningResponse.class);
        util.exportExcel(response, list, "预警表数据");
    }

    /**
     * 获取预警表详细信息
     */
    @RequiresPermissions("storage:forewarning:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(wmsForewarningService.selectWmsForewarningById(id));
    }

    /**
     * 新增预警表
     */
    @RequiresPermissions("storage:forewarning:add")
    @Log(title = "预警表", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody WmsForewarning wmsForewarning)
    {
        return toAjax(wmsForewarningService.insertWmsForewarning(wmsForewarning));
    }

    /**
     * 修改预警表
     */
    @RequiresPermissions("storage:forewarning:edit")
    @Log(title = "预警表", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody WmsForewarning wmsForewarning)
    {
        return toAjax(wmsForewarningService.updateWmsForewarning(wmsForewarning));
    }

    /**
     * 删除预警表
     */
    @RequiresPermissions("storage:forewarning:remove")
    @Log(title = "预警表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsForewarningService.deleteWmsForewarningByIds(ids));
    }



}
